#!/usr/bin/env python
#-*- coding: utf-8 -*-
#=============================================================================
#     FileName:
#         Desc:
#       Author: 苦咖啡
#        Email: voilet@qq.com
#     HomePage: http://blog.kukafei520.net
#      Version: 0.0.1
#   LastChange: 
#      History:
#=============================================================================
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.core.context_processors import csrf
from django.shortcuts import get_object_or_404
from assets.models import Project, ProjectUser
#日志记录
#登录
from accounts.auth_login.auth_index_class import auth_login_required


@auth_login_required()
def node(request, id):
    context = {}
    user = request.user
    myform_item = get_object_or_404(Project, pk=id)
    my_business = ProjectUser.objects.filter(myform = myform_item, user = user)
    if len(my_business) >0 :
        node_list = myform_item.host_set.all()
        context["node"] = node_list
        context.update(csrf(request))
        context["status"] = True
        return render_to_response('saltstack/server_type_node.html', context, context_instance=RequestContext(request))
    context["status"] = False
    return render_to_response('saltstack/server_type_node.html', context, context_instance=RequestContext(request))
